import storageUtil from '@/utils/StorageUtil'

// local storage Key常量
export const PageVersionKey = 'ps_TmptTable-page-version-key'
export const ConditionShowListCkedKey = 'ps_TmptTable-condition-column-show-cked-list-key'
export const ColumnShowListCkedKey = 'ps_TmptTable-list-column-show-cked-list-key'
export const isDropMenuKey = 'ps_TmptTable-list-column-show-isdropmenu-key'
export const ColumnShowListWidthKey = 'ps_TmptTable-list-column-width-key'
export const IsExpandedRowCkedKey = 'ps_TmptTable-list-isexpanded-row-key'


// 查询条件 type: input/date/date-range/num-range/select/tree/
export const conditionOptions = [
  { property: 'hasdelbtn', label: 'hasdelbtn', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Hasdelbtn', remoteUrl: '' },
  { property: 'hascompanyid', label: 'hascompanyid', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Hascompanyid', remoteUrl: '' },
  { property: 'styleAdddialog', label: 'styleAdddialog', width: 200, show: true, type: 'input', dataResource: 0, enumName:'StyleAdddialog', remoteUrl: '' },
  { property: 'isdialogAdddialog', label: 'isdialogAdddialog', width: 200, show: true, type: 'input', dataResource: 0, enumName:'IsdialogAdddialog', remoteUrl: '' },
  { property: 'treeJson', label: 'treeJson', width: 200, show: true, type: 'input', dataResource: 0, enumName:'TreeJson', remoteUrl: '' },
  { property: 'id', label: 'ID', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Id', remoteUrl: '' },
  { property: 'keyrandom', label: 'keyrandom', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Keyrandom', remoteUrl: '' },
  { property: 'mode', label: 'mode', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Mode', remoteUrl: '' },
  { property: 'primarykey', label: 'primarykey', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Primarykey', remoteUrl: '' },
  { property: 'tablename', label: 'tablename', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Tablename', remoteUrl: '' },
  { property: 'tablenameshow', label: 'tablenameshow', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Tablenameshow', remoteUrl: '' },
  { property: 'one2many', label: 'one2many', width: 200, show: true, type: 'input', dataResource: 0, enumName:'One2many', remoteUrl: '' },
  { property: 'hasaddbtn', label: 'hasaddbtn', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Hasaddbtn', remoteUrl: '' },
  { property: 'hasdownloadreportbtn', label: 'hasdownloadreportbtn', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Hasdownloadreportbtn', remoteUrl: '' },
  { property: 'haseditbtn', label: 'haseditbtn', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Haseditbtn', remoteUrl: '' },
  { property: 'hashistorybtn', label: 'hashistorybtn', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Hashistorybtn', remoteUrl: '' },
  { property: 'beanmethod', label: 'beanmethod', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Beanmethod', remoteUrl: '' },
  { property: 'beanobject', label: 'beanobject', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Beanobject', remoteUrl: '' },
  { property: 'beanhistorymethod', label: 'beanhistorymethod', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Beanhistorymethod', remoteUrl: '' },
  { property: 'tablealiasname', label: 'tablealiasname', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Tablealiasname', remoteUrl: '' },
  { property: 'sqlcount', label: 'sqlcount', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Sqlcount', remoteUrl: '' },
  { property: 'tablenamehistorysql', label: 'tablenamehistorysql', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Tablenamehistorysql', remoteUrl: '' },
  { property: 'tablenamesql', label: 'tablenamesql', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Tablenamesql', remoteUrl: '' },
  { property: 'sqlcounthistory', label: 'sqlcounthistory', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Sqlcounthistory', remoteUrl: '' },
  { property: 'sqlpage', label: 'sqlpage', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Sqlpage', remoteUrl: '' },
  { property: 'sqlpagehistory', label: 'sqlpagehistory', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Sqlpagehistory', remoteUrl: '' },
  { property: 'sqlreport', label: 'sqlreport', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Sqlreport', remoteUrl: '' },
  { property: 'sqlsum', label: 'sqlsum', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Sqlsum', remoteUrl: '' },
  { property: 'createdate', label: '创建日期', width: 200, show: true, type: 'date-range', dataResource: 0, enumName:'Createdate', remoteUrl: '' },
  { property: 'deleteflag', label: '删除标志', width: 200, show: true, type: 'select', dataResource: 1, enumName:'Deleteflag', remoteUrl: '/core/enum/getData4AddBy' },
  { property: 'foreignkey', label: 'foreignkey', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Foreignkey', remoteUrl: '' },
  { property: 'sqlprocedure', label: 'sqlprocedure', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Sqlprocedure', remoteUrl: '' },
  { property: 'height4adddialog', label: 'height4adddialog', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Height4adddialog', remoteUrl: '' },
  { property: 'width4adddialog', label: 'width4adddialog', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Width4adddialog', remoteUrl: '' },
  { property: 'chartjson', label: 'chartjson', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Chartjson', remoteUrl: '' },
  { property: 'chartheight', label: 'chartheight', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Chartheight', remoteUrl: '' },
  { property: 'chartwidth', label: 'chartwidth', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Chartwidth', remoteUrl: '' },
  { property: 'interceptaddmethod', label: 'interceptaddmethod', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Interceptaddmethod', remoteUrl: '' },
  { property: 'intercepteditmethod', label: 'intercepteditmethod', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Intercepteditmethod', remoteUrl: '' },
  { property: 'interceptobject', label: 'interceptobject', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Interceptobject', remoteUrl: '' },
  { property: 'hascheckbox', label: 'hascheckbox', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Hascheckbox', remoteUrl: '' },
  { property: 'datasource', label: 'datasource', width: 200, show: true, type: 'input', dataResource: 0, enumName:'Datasource', remoteUrl: '' }
]
// 所有列对象
export const theadOptions = [
      { property: 'hasdelbtn', label: 'hasdelbtn', width: storageUtil.getColumnWidthFromStorage('hasdelbtn', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'hascompanyid', label: 'hascompanyid', width: storageUtil.getColumnWidthFromStorage('hascompanyid', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'styleAdddialog', label: 'styleAdddialog', width: storageUtil.getColumnWidthFromStorage('styleAdddialog', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'isdialogAdddialog', label: 'isdialogAdddialog', width: storageUtil.getColumnWidthFromStorage('isdialogAdddialog', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'treeJson', label: 'treeJson', width: storageUtil.getColumnWidthFromStorage('treeJson', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'id', label: 'ID', width: storageUtil.getColumnWidthFromStorage('id', 150, ColumnShowListWidthKey), show: true, edit: false, sort: 'custom', fixed: false} ,
      { property: 'keyrandom', label: 'keyrandom', width: storageUtil.getColumnWidthFromStorage('keyrandom', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'mode', label: 'mode', width: storageUtil.getColumnWidthFromStorage('mode', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'primarykey', label: 'primarykey', width: storageUtil.getColumnWidthFromStorage('primarykey', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'tablename', label: 'tablename', width: storageUtil.getColumnWidthFromStorage('tablename', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'tablenameshow', label: 'tablenameshow', width: storageUtil.getColumnWidthFromStorage('tablenameshow', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'one2many', label: 'one2many', width: storageUtil.getColumnWidthFromStorage('one2many', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'hasaddbtn', label: 'hasaddbtn', width: storageUtil.getColumnWidthFromStorage('hasaddbtn', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'hasdownloadreportbtn', label: 'hasdownloadreportbtn', width: storageUtil.getColumnWidthFromStorage('hasdownloadreportbtn', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'haseditbtn', label: 'haseditbtn', width: storageUtil.getColumnWidthFromStorage('haseditbtn', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'hashistorybtn', label: 'hashistorybtn', width: storageUtil.getColumnWidthFromStorage('hashistorybtn', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'beanmethod', label: 'beanmethod', width: storageUtil.getColumnWidthFromStorage('beanmethod', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'beanobject', label: 'beanobject', width: storageUtil.getColumnWidthFromStorage('beanobject', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'beanhistorymethod', label: 'beanhistorymethod', width: storageUtil.getColumnWidthFromStorage('beanhistorymethod', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'tablealiasname', label: 'tablealiasname', width: storageUtil.getColumnWidthFromStorage('tablealiasname', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'sqlcount', label: 'sqlcount', width: storageUtil.getColumnWidthFromStorage('sqlcount', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'tablenamehistorysql', label: 'tablenamehistorysql', width: storageUtil.getColumnWidthFromStorage('tablenamehistorysql', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'tablenamesql', label: 'tablenamesql', width: storageUtil.getColumnWidthFromStorage('tablenamesql', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'sqlcounthistory', label: 'sqlcounthistory', width: storageUtil.getColumnWidthFromStorage('sqlcounthistory', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'sqlpage', label: 'sqlpage', width: storageUtil.getColumnWidthFromStorage('sqlpage', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'sqlpagehistory', label: 'sqlpagehistory', width: storageUtil.getColumnWidthFromStorage('sqlpagehistory', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'sqlreport', label: 'sqlreport', width: storageUtil.getColumnWidthFromStorage('sqlreport', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'sqlsum', label: 'sqlsum', width: storageUtil.getColumnWidthFromStorage('sqlsum', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'createdate', label: '创建日期', width: storageUtil.getColumnWidthFromStorage('createdate', 150, ColumnShowListWidthKey), show: true, edit: false, sort: false, fixed: false} ,
      { property: 'createman', label: '创建人', width: storageUtil.getColumnWidthFromStorage('createman', 150, ColumnShowListWidthKey), show: true, edit: false, sort: false, fixed: false} ,
      // 枚举对象， json结构，如: {'id':1, 'name':'无效'}
      { property: 'deleteflag.name', label: '删除标志', width: storageUtil.getColumnWidthFromStorage('deleteflag.name', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false, dataResource: 1, columnType: 'select', enumName:'Deleteflag', remoteUrl: '/core/enum/getData4AddBy'} ,
      { property: 'modifydate', label: '修改日期', width: storageUtil.getColumnWidthFromStorage('modifydate', 150, ColumnShowListWidthKey), show: true, edit: false, sort: false, fixed: false} ,
      { property: 'modifyman', label: '修改人', width: storageUtil.getColumnWidthFromStorage('modifyman', 150, ColumnShowListWidthKey), show: true, edit: false, sort: false, fixed: false} ,
      { property: 'foreignkey', label: 'foreignkey', width: storageUtil.getColumnWidthFromStorage('foreignkey', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'sqlprocedure', label: 'sqlprocedure', width: storageUtil.getColumnWidthFromStorage('sqlprocedure', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'height4adddialog', label: 'height4adddialog', width: storageUtil.getColumnWidthFromStorage('height4adddialog', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'width4adddialog', label: 'width4adddialog', width: storageUtil.getColumnWidthFromStorage('width4adddialog', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'chartjson', label: 'chartjson', width: storageUtil.getColumnWidthFromStorage('chartjson', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'chartheight', label: 'chartheight', width: storageUtil.getColumnWidthFromStorage('chartheight', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'chartwidth', label: 'chartwidth', width: storageUtil.getColumnWidthFromStorage('chartwidth', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'interceptaddmethod', label: 'interceptaddmethod', width: storageUtil.getColumnWidthFromStorage('interceptaddmethod', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'intercepteditmethod', label: 'intercepteditmethod', width: storageUtil.getColumnWidthFromStorage('intercepteditmethod', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'interceptobject', label: 'interceptobject', width: storageUtil.getColumnWidthFromStorage('interceptobject', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'hascheckbox', label: 'hascheckbox', width: storageUtil.getColumnWidthFromStorage('hascheckbox', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} ,
      { property: 'datasource', label: 'datasource', width: storageUtil.getColumnWidthFromStorage('datasource', 150, ColumnShowListWidthKey), show: true, edit: true, sort: false, fixed: false} 
]

export const pickerOptions = {
  shortcuts: [{
    text: '最近一周',
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
      picker.$emit('pick', [start, end])
    }
  }, {
    text: '最近一个月',
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
      picker.$emit('pick', [start, end])
    }
  }, {
    text: '最近三个月',
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
      picker.$emit('pick', [start, end])
    }
  }]
}

export const pickerOptionsSingleDate = {
  disabledDate(time) {
    return time.getTime() > Date.now()
  },
  shortcuts: [{
    text: '今天',
    onClick(picker) {
      picker.$emit('pick', new Date())
    }
  }, {
    text: '昨天',
    onClick(picker) {
      const date = new Date()
      date.setTime(date.getTime() - 3600 * 1000 * 24)
      picker.$emit('pick', date)
    }
  }, {
    text: '一周前',
    onClick(picker) {
      const date = new Date()
      date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
      picker.$emit('pick', date)
    }
  }]
}
